
a = [1]
b = [3,4,5,6,7]

def median(a,b):
    result = merge(a,b)

    l = len(result)
    if l %2 == 0:
        return (result[l//2-1]+result[l//2])/2.0
    else:
        return result[(l+1)//2-1]

def merge(a,b):
    i=0
    j=0
    m = len(a)
    n = len(b)
    result = []
    while i<m and j<n:
        if a[i]<b[j]:
            result.append(a[i])
            i+=1
        else:
            result.append(b[j])
            j+=1
    for k in range(i,m):
        result.append(a[k])
    for k in range(j,n):
        result.append(b[k])
    return result

print(median(a,b))